﻿
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using Common.DBUtility;
using lib.Model;
namespace lib.DAL
{
    /// <summary>
    /// 类MenuInfo_Dal
    /// 此文件由CoderGoCodeBuilder v1.0自动生成，请不要手动修改此文件，以便日后自动覆盖
    /// 2017-01-22 10:03:22
    /// </summary>
    [Serializable]
    public partial class MenuInfo_Dal : SQL_DAL_Base
    {
    private const string SQL_INSERT_MENUINFO = @"INSERT INTO MenuInfo
  (FdMenuName,FdMenuCode,FdMenuParentID,FdMenuUrl,FdMenuSort,FdMenuIsEnable,FdMenuDescription,FdMenuIsTarget,FdMenuParentIDs,FdMenuIsMenuLast,FdMenuIcon)
    VALUES (@FdMenuName,@FdMenuCode,@FdMenuParentID,@FdMenuUrl,@FdMenuSort,@FdMenuIsEnable,@FdMenuDescription,@FdMenuIsTarget,@FdMenuParentIDs,@FdMenuIsMenuLast,@FdMenuIcon)";
      private const string PARM_FD_MENU_ID = "@FdMenuID";
      private const string PARM_FD_MENU_NAME = "@FdMenuName";
      private const string PARM_FD_MENU_CODE = "@FdMenuCode";
      private const string PARM_FD_MENU_PARENT_ID = "@FdMenuParentID";
      private const string PARM_FD_MENU_URL = "@FdMenuUrl";
      private const string PARM_FD_MENU_SORT = "@FdMenuSort";
      private const string PARM_FD_MENU_IS_ENABLE = "@FdMenuIsEnable";
      private const string PARM_FD_MENU_DESCRIPTION = "@FdMenuDescription";
      private const string PARM_FD_MENU_IS_TARGET = "@FdMenuIsTarget";
      private const string PARM_FD_MENU_PARENT_IDS = "@FdMenuParentIDs";
      private const string PARM_FD_MENU_IS_MENU_LAST = "@FdMenuIsMenuLast";
      private const string PARM_FD_MENU_ICON = "@FdMenuIcon";
    public static readonly MenuInfo_Dal Instance;
    static MenuInfo_Dal()
    {
        Instance = new MenuInfo_Dal();
        Instance.InstanceInited();
    }
    private MenuInfo_Dal()
    {
        tableOrViewName = "MenuInfo";
        primeryKeyNames = "fdMenuID"; 
    }
    /// <summary>
    /// 将model实体以一条数据记录插入数据表
    /// 此方法为自动生成，请不要手动修改
    /// </summary>
    /// <param name="model">要以记录插入数据库的对象</param>
    /// <returns>返回自增的FdMenuID的新增值</returns>
    public int Add(MenuInfo_Model model)
    {
        return Add(model,null);
    }
    /// <summary>
    /// 将model实体以一条数据记录插入数据表, 使用事务
    /// 此方法为自动生成，请不要手动修改
    /// </summary>
    /// <param name="model">要以记录插入数据库的对象</param>
    /// <param name="model">使用的事务对象,可为null </param>
    /// <returns>FdMenuID</returns>
    public int Add(MenuInfo_Model model, SqlTransaction trans)
    {
    SqlParameter[] parameters = GetMenuInfoParameters();
      if(model.FdMenuID == null) parameters[0].Value=0; //有可能出现与业务逻辑有关的问题
      else parameters[0].Value = model.FdMenuID;
      if(model.FdMenuName == null) parameters[1].Value=""; //有可能出现与业务逻辑有关的问题
      else parameters[1].Value = model.FdMenuName;
      if(model.FdMenuCode == null) parameters[2].Value=""; //有可能出现与业务逻辑有关的问题
      else parameters[2].Value = model.FdMenuCode;
      if(model.FdMenuParentID == null) parameters[3].Value=0; //有可能出现与业务逻辑有关的问题
      else parameters[3].Value = model.FdMenuParentID;
      if(model.FdMenuUrl == null) parameters[4].Value=""; //有可能出现与业务逻辑有关的问题
      else parameters[4].Value = model.FdMenuUrl;
      if(model.FdMenuSort == null) parameters[5].Value=1; //有可能出现与业务逻辑有关的问题
      else parameters[5].Value = model.FdMenuSort;
      if(model.FdMenuIsEnable == null) parameters[6].Value=1; //有可能出现与业务逻辑有关的问题
      else parameters[6].Value = model.FdMenuIsEnable;
      if(model.FdMenuDescription == null) parameters[7].Value=DBNull.Value;
      else parameters[7].Value = model.FdMenuDescription;
      if(model.FdMenuIsTarget == null) parameters[8].Value=1; //有可能出现与业务逻辑有关的问题
      else parameters[8].Value = model.FdMenuIsTarget;
      if(model.FdMenuParentIDs == null) parameters[9].Value=DBNull.Value;
      else parameters[9].Value = model.FdMenuParentIDs;
      if(model.FdMenuIsMenuLast == null) parameters[10].Value=1; //有可能出现与业务逻辑有关的问题
      else parameters[10].Value = model.FdMenuIsMenuLast;
      if(model.FdMenuIcon == null) parameters[11].Value=DBNull.Value;
      else parameters[11].Value = model.FdMenuIcon;
        if(trans==null)
        {
            return int.Parse(SqlHelperWebDAL.ExecuteScalar(CommandType.Text, SQL_INSERT_MENUINFO+";select @@IDENTITY", parameters).ToString());
        }
        else
        {
            return int.Parse(SqlHelperWebDAL.ExecuteScalar(trans, CommandType.Text, SQL_INSERT_MENUINFO+";select @@IDENTITY", parameters).ToString());
        }
    }
    /// <summary>
    /// 根据model更新该实体对应的数据表记录的所有字段，返回受影响的行数
    /// 此方法为自动生成，请不要手动修改
    /// </summary>
    /// <param name="model">要更新的实体对象</param>
    /// <returns>受影响的行数</returns>
    public int Update(MenuInfo_Model model)
    {
         return Update("FdMenuName=@FdMenuName,FdMenuCode=@FdMenuCode,FdMenuParentID=@FdMenuParentID,FdMenuUrl=@FdMenuUrl,FdMenuSort=@FdMenuSort,FdMenuIsEnable=@FdMenuIsEnable,FdMenuDescription=@FdMenuDescription,FdMenuIsTarget=@FdMenuIsTarget,FdMenuParentIDs=@FdMenuParentIDs,FdMenuIsMenuLast=@FdMenuIsMenuLast,FdMenuIcon=@FdMenuIcon", model);
    }
    /// <summary>
    /// 使用事务，根据model更新该实体对应的数据表记录的所有字段，返回受影响的行数
    /// 此方法为自动生成，请不要手动修改
    /// </summary>
    /// <param name="trans">使用的事务,可以为null</param>
    /// <param name="model">要更新的记录对象</param>
    /// <returns>受影响的行数</returns>
    public int Update(SqlTransaction trans, MenuInfo_Model model)
    {
         return Update(trans,"FdMenuName=@FdMenuName,FdMenuCode=@FdMenuCode,FdMenuParentID=@FdMenuParentID,FdMenuUrl=@FdMenuUrl,FdMenuSort=@FdMenuSort,FdMenuIsEnable=@FdMenuIsEnable,FdMenuDescription=@FdMenuDescription,FdMenuIsTarget=@FdMenuIsTarget,FdMenuParentIDs=@FdMenuParentIDs,FdMenuIsMenuLast=@FdMenuIsMenuLast,FdMenuIcon=@FdMenuIcon", model);
    }
    /// <summary>
    /// 根据model更新该实体对应的数据表记录，可指定部分行，返回受影响的行数
    /// 此方法为自动生成，请不要手动修改
    /// </summary>
    /// <param name="UpdateSql">指定更新SQL(不含set)</param>
    /// <param name="model">要更新的记录对象</param>
    /// <returns>受影响的行数</returns>
    public int Update(string UpdateSql, MenuInfo_Model model)
    {
        return Update(null,UpdateSql,model);
    }
    /// <summary>
    /// 使用事务，根据model更新该实体对应的数据表记录，可指定部分行，返回受影响的行数
    /// 此方法为自动生成，请不要手动修改
    /// </summary>
    /// <param name="trans">使用的事务,可以为null</param>
    /// <param name="UpdateSql">指定更新SQL(不含set)</param>
    /// <param name="model">要更新的记录对象</param>
    /// <returns>受影响的行数</returns>
    public int Update(SqlTransaction trans, string UpdateSql, MenuInfo_Model model)
    {
    if(UpdateSql.Trim()=="") throw new Exception("请指定更新细节");
    SqlParameter[] parameters = GetMenuInfoParameters();
      if(model.FdMenuID == null) parameters[0].Value=0; //有可能出现与业务逻辑有关的问题
      else parameters[0].Value = model.FdMenuID;
      if(model.FdMenuName == null) parameters[1].Value=""; //有可能出现与业务逻辑有关的问题
      else parameters[1].Value = model.FdMenuName;
      if(model.FdMenuCode == null) parameters[2].Value=""; //有可能出现与业务逻辑有关的问题
      else parameters[2].Value = model.FdMenuCode;
      if(model.FdMenuParentID == null) parameters[3].Value=0; //有可能出现与业务逻辑有关的问题
      else parameters[3].Value = model.FdMenuParentID;
      if(model.FdMenuUrl == null) parameters[4].Value=""; //有可能出现与业务逻辑有关的问题
      else parameters[4].Value = model.FdMenuUrl;
      if(model.FdMenuSort == null) parameters[5].Value=1; //有可能出现与业务逻辑有关的问题
      else parameters[5].Value = model.FdMenuSort;
      if(model.FdMenuIsEnable == null) parameters[6].Value=1; //有可能出现与业务逻辑有关的问题
      else parameters[6].Value = model.FdMenuIsEnable;
      if(model.FdMenuDescription == null) parameters[7].Value=DBNull.Value;
      else parameters[7].Value = model.FdMenuDescription;
      if(model.FdMenuIsTarget == null) parameters[8].Value=1; //有可能出现与业务逻辑有关的问题
      else parameters[8].Value = model.FdMenuIsTarget;
      if(model.FdMenuParentIDs == null) parameters[9].Value=DBNull.Value;
      else parameters[9].Value = model.FdMenuParentIDs;
      if(model.FdMenuIsMenuLast == null) parameters[10].Value=1; //有可能出现与业务逻辑有关的问题
      else parameters[10].Value = model.FdMenuIsMenuLast;
      if(model.FdMenuIcon == null) parameters[11].Value=DBNull.Value;
      else parameters[11].Value = model.FdMenuIcon;
    if(trans==null) return SqlHelperWebDAL.ExecuteNonQuery(CommandType.Text, "update MenuInfo set " + UpdateSql + " where FdMenuID=@FdMenuID", parameters);
    else return SqlHelperWebDAL.ExecuteNonQuery(trans, CommandType.Text, "update MenuInfo set " + UpdateSql + " where FdMenuID=@FdMenuID", parameters);
    }
    /// <summary>
    /// 根据主键删除该实体对应的数据表记录，返回受影响的行数
    /// 此方法为自动生成，请不要手动修改
    /// </summary>
    /// <returns>受影响的行数</returns>
    public int Delete(int fdMenuID)
    {
         return Delete(null,fdMenuID);
    }
    /// <summary>
    /// 使用事务，根据主键删除该实体对应的数据表记录，返回受影响的行数
    /// 此方法为自动生成，请不要手动修改
    /// </summary>
    /// <param name="trans">使用的事务,可以为null</param>
    /// <returns>受影响的行数</returns>
    public int Delete(SqlTransaction trans, int fdMenuID)
    {
	if(trans==null) return SqlHelperWebDAL.ExecuteNonQuery(CommandType.Text,"delete MenuInfo where FdMenuID=@FdMenuID",new SqlParameter("@FdMenuID",fdMenuID));
	else return SqlHelperWebDAL.ExecuteNonQuery(trans,CommandType.Text,"delete MenuInfo where FdMenuID=@FdMenuID",new SqlParameter("@FdMenuID",fdMenuID));
    }
    /// <summary>
    /// 根据主键返回实体对象
    /// </summary>
    /// <returns></returns>
    public MenuInfo_Model GetModelByID(int fdMenuID)
    {
    return GetModel("FdMenuID=@FdMenuID", new SqlParameter("@FdMenuID",fdMenuID)
    );
    }
    /// <summary>
    /// 根据主键返回实体对象
    /// </summary>
    /// <returns></returns>
    public MenuInfo_Model GetModelByID(int fdMenuID,SqlTransaction trans)
    {
        return GetModel("FdMenuID=@FdMenuID", trans, new SqlParameter("@FdMenuID",fdMenuID)
              );
    }
    /// <summary>
    /// 根据主键返回实体对象
    /// </summary>
    /// <returns></returns>
    public MenuInfo_Model GetModelByID(int fdMenuID,string selectFeilds,SqlTransaction trans)
    {
        return GetModel("FdMenuID=@FdMenuID",selectFeilds ,trans, new SqlParameter("@FdMenuID",fdMenuID)
        );
    }
    /// <summary>
    /// 将记录转换成实体对象
    /// </summary>
    /// <param name="dr"></param>
    /// <returns></returns>
    public MenuInfo_Model GetModel(SqlDataReader dr)
    {
        MenuInfo_Model model = new MenuInfo_Model();
        for (int i = 0; i < dr.FieldCount; i++)
    {
          switch(dr.GetName(i).ToLower())
          {
                case "fdmenuid":
                    model.FdMenuID=SqlHelper.GetInt(dr["FdMenuID"]);
                    break;
                case "fdmenuname":
                    model.FdMenuName=SqlHelper.GetString(dr["FdMenuName"]);
                    break;
                case "fdmenucode":
                    model.FdMenuCode=SqlHelper.GetString(dr["FdMenuCode"]);
                    break;
                case "fdmenuparentid":
                    model.FdMenuParentID=SqlHelper.GetInt(dr["FdMenuParentID"]);
                    break;
                case "fdmenuurl":
                    model.FdMenuUrl=SqlHelper.GetString(dr["FdMenuUrl"]);
                    break;
                case "fdmenusort":
                    model.FdMenuSort=SqlHelper.GetInt(dr["FdMenuSort"]);
                    break;
                case "fdmenuisenable":
                    model.FdMenuIsEnable=SqlHelper.GetBool(dr["FdMenuIsEnable"]);
                    break;
                case "fdmenudescription":
                    model.FdMenuDescription=SqlHelper.GetString(dr["FdMenuDescription"]);
                    break;
                case "fdmenuistarget":
                    model.FdMenuIsTarget=SqlHelper.GetInt(dr["FdMenuIsTarget"]);
                    break;
                case "fdmenuparentids":
                    model.FdMenuParentIDs=SqlHelper.GetString(dr["FdMenuParentIDs"]);
                    break;
                case "fdmenuismenulast":
                    model.FdMenuIsMenuLast=SqlHelper.GetBool(dr["FdMenuIsMenuLast"]);
                    break;
                case "fdmenuicon":
                    model.FdMenuIcon=SqlHelper.GetString(dr["FdMenuIcon"]);
                    break;
                default:break;
           }
       }
       return model;
    }
    /// <summary>
    /// 将记录转换成实体对象
    /// </summary>
    /// <param name="dr"></param>
    /// <returns></returns>
    public MenuInfo_Model GetModel(DataRow dr)
    {
          MenuInfo_Model model = new MenuInfo_Model();
        for (int i = 0; i < dr.Table.Columns.Count; i++)
        {
          switch(dr.Table.Columns[i].ColumnName.ToLower())
          {
            case "fdmenuid":
            model.FdMenuID=SqlHelper.GetInt(dr["FdMenuID"]);
            break;
            case "fdmenuname":
            model.FdMenuName=SqlHelper.GetString(dr["FdMenuName"]);
            break;
            case "fdmenucode":
            model.FdMenuCode=SqlHelper.GetString(dr["FdMenuCode"]);
            break;
            case "fdmenuparentid":
            model.FdMenuParentID=SqlHelper.GetInt(dr["FdMenuParentID"]);
            break;
            case "fdmenuurl":
            model.FdMenuUrl=SqlHelper.GetString(dr["FdMenuUrl"]);
            break;
            case "fdmenusort":
            model.FdMenuSort=SqlHelper.GetInt(dr["FdMenuSort"]);
            break;
            case "fdmenuisenable":
            model.FdMenuIsEnable=SqlHelper.GetBool(dr["FdMenuIsEnable"]);
            break;
            case "fdmenudescription":
            model.FdMenuDescription=SqlHelper.GetString(dr["FdMenuDescription"]);
            break;
            case "fdmenuistarget":
            model.FdMenuIsTarget=SqlHelper.GetInt(dr["FdMenuIsTarget"]);
            break;
            case "fdmenuparentids":
            model.FdMenuParentIDs=SqlHelper.GetString(dr["FdMenuParentIDs"]);
            break;
            case "fdmenuismenulast":
            model.FdMenuIsMenuLast=SqlHelper.GetBool(dr["FdMenuIsMenuLast"]);
            break;
            case "fdmenuicon":
            model.FdMenuIcon=SqlHelper.GetString(dr["FdMenuIcon"]);
            break;
          default:break;
          }
        }
        return model;
  }
    /// <summary>
    /// 返回符合条件的第一个对象
    /// </summary>
    /// <param name="conditionSql">条件SQL(不含where)</param>
    /// <param name="parms">SQL参数</param>
    /// <returns>返回符合条件的第一个对象</returns>
    public MenuInfo_Model GetModel(string conditionSql, params SqlParameter[] parms)
    {
        return GetModel(conditionSql,"*", parms);
    }
    /// <summary>
    /// 返回符合条件的第一个对象
    /// </summary>
    /// <param name="conditionSql">条件SQL(不含where)</param>
    /// <param name="selectFields">返回属性（列），为空或null则返回所有属性（列）</param>
    /// <param name="parms">SQL参数</param>
    /// <returns>返回符合条件的第一个对象</returns>
    public MenuInfo_Model GetModel(string conditionSql, string selectFields, params SqlParameter[] parms)
    {
        MenuInfo_Model model = null;
        using (SqlDataReader dr = SqlHelperWebDAL.ExecuteReader(CommandType.Text, "select top 1 "+(string.IsNullOrEmpty(selectFields)?"*":selectFields)+" from MenuInfo " + ((conditionSql.Trim() == "") ? "" : ("where " + conditionSql)), parms))
        {
            if (dr.Read()) model = GetModel(dr);
        }
        return model;
    }
    /// <summary>
    /// 返回符合条件的第一个对象
    /// </summary>
    /// <param name="conditionSql">条件SQL(不含where)</param>
    /// <param name="trans">事务(可为null)</param>
    /// <param name="parms">SQL参数</param>
    /// <returns>返回符合条件的第一个对象</returns>
    public MenuInfo_Model GetModel(string conditionSql, SqlTransaction trans, params SqlParameter[] parms)
    {
        return GetModel(conditionSql,"*",trans,parms);
    }
    /// <summary>
    /// 返回符合条件的第一个对象
    /// </summary>
    /// <param name="conditionSql">条件SQL(不含where)</param>
    /// <param name="selectFields">返回属性（列），为空或null则返回所有属性（列）</param>
    /// <param name="trans">事务(可为null)</param>
    /// <param name="parms">SQL参数</param>
    /// <returns>返回符合条件的第一个对象</returns>
    public MenuInfo_Model GetModel(string conditionSql, string selectFields, SqlTransaction trans, params SqlParameter[] parms)
    {
        if (trans == null) return GetModel(conditionSql,selectFields, parms);
        MenuInfo_Model model = null;
        DataTable dt = SqlHelperWebDAL.GetDataSet(trans, CommandType.Text, "select top 1 "+(string.IsNullOrEmpty(selectFields)?"*":selectFields)+" from MenuInfo " + ((conditionSql.Trim() == "") ? "" : ("where " + conditionSql)), parms).Tables[0];
        if (dt.Rows.Count > 0) model = GetModel(dt.Rows[0]);
        return model;
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="sql">完整的SQL</param>
    /// <param name="parms"></param>
    /// <returns></returns>
    public IList<MenuInfo_Model> GetModelList(string sql, params SqlParameter[] parms)
    {
        IList<MenuInfo_Model>
        modelList = new List<MenuInfo_Model>();
        using (SqlDataReader dr = SqlHelperWebDAL.ExecuteReader(CommandType.Text, sql, parms))
        {
        while (dr.Read()) modelList.Add(GetModel(dr));
        }
        return modelList;
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns></returns>
    public IList<MenuInfo_Model> GetModelList(string conditionSql, string selectFields, string orderBy, params SqlParameter[] parms)
    {
        return GetModelList(conditionSql, selectFields, orderBy, null, parms);
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="trans">事务(可为null)</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns></returns>
    public IList<MenuInfo_Model> GetModelList(string conditionSql, string selectFields, string orderBy, SqlTransaction trans, params SqlParameter[] parms)
    {
        IList<MenuInfo_Model>
        modelList = new List<MenuInfo_Model>();
        foreach(DataRow dr in GetList(conditionSql,selectFields,orderBy, trans,parms).Rows)
        {
            modelList.Add(GetModel(dr));
        }
        return modelList;
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// MSSQL2005及以上可用
    /// </summary>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelList(ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
    {
         return GetModelListMSSQL2005(ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录
    /// MSSQL2005及以上可用
    /// </summary>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelList(string conditionSql, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
    {
        return GetModelListMSSQL2005(conditionSql, orderBy, pageSize, pageIndex, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// MSSQL2005及以上可用
    /// </summary>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="pageRecordOffset">分页时的偏移值（前面pageRecordOffset条使用其他方式或其他条件取出，小于0则表示最前面pageRecordOffset条记录被忽略）</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelList(ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, int pageRecordOffset, params SqlParameter[] parms)
    {
        return GetModelListMSSQL2005(ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, pageRecordOffset, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录
    /// MSSQL2005及以上可用
    /// </summary>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="pageRecordOffset">分页时的偏移值（前面pageRecordOffset条使用其他方式或其他条件取出，小于0则表示最前面pageRecordOffset条记录被忽略）</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelList(string conditionSql, string orderBy, int pageSize, int pageIndex, int pageRecordOffset, params SqlParameter[] parms)
    {
        return GetModelListMSSQL2005(conditionSql, orderBy, pageSize, pageIndex, pageRecordOffset, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// MSSQL2005及以上可用
    /// </summary>
    /// <param name="joinSql">join语句，如inner Join B on MenuInfo.fdMenuID=B.fdMenuID</param>
    /// <param name="throwSql">将SQL语句作为异常抛出，用于检测语句正确性</param>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelList_JOIN(string joinSql,bool throwSql,ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
    {
        return GetModelList_JOIN(joinSql,throwSql,ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, 0, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// MSSQL2005及以上可用
    /// </summary>
    /// <param name="joinSql">join语句，如inner Join B on MenuInfo.fdMenuID=B.fdMenuID</param>
    /// <param name="throwSql">将SQL语句作为异常抛出，用于检测语句正确性</param>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="pageRecordOffset">分页时的偏移值（前面pageRecordOffset条使用其他方式或其他条件取出）</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelList_JOIN(string joinSql,bool throwSql,ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex,int pageRecordOffset, params SqlParameter[] parms)
    {
        return GetModelListMSSQL2005_JOIN(joinSql,throwSql,ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex,pageRecordOffset, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// 注意：仅MSSQL2005及以上可用
    /// </summary>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2005(ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
    {
        return GetModelListMSSQL2005(ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, 0, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// 注意：仅MSSQL2005及以上可用
    /// </summary>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="pageRecordOffset">分页时的偏移值（前面pageRecordOffset条使用其他方式或其他条件取出）</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2005(ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, int pageRecordOffset, params SqlParameter[] parms)
    {
        DataTable dt = GetListMSSQL2005(ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, pageRecordOffset, parms);
        IList<MenuInfo_Model>
        modelList = new List<MenuInfo_Model>();
        foreach(DataRow dr in dt.Rows) modelList.Add(GetModel(dr));
        return modelList;
    }
    /// <summary>
    /// 分页返回符合条件的记录
    /// 注意：仅MSSQL2005及以上可用
    /// </summary>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2005(string conditionSql, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
    {
        return GetModelListMSSQL2005(conditionSql, orderBy, pageSize, pageIndex, 0, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录
    /// 注意：仅MSSQL2005及以上可用
    /// </summary>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="pageRecordOffset">分页时的偏移值（前面pageRecordOffset条使用其他方式或其他条件取出）</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2005(string conditionSql, string orderBy, int pageSize, int pageIndex, int pageRecordOffset, params SqlParameter[] parms)
    {
        string sql = SqlHelper.GetPageSQL_MSSQL2005(TableOrViewName, PrimeryKeyNames, conditionSql, "*", orderBy, pageSize, pageIndex, pageRecordOffset);
        return GetModelList(sql, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// 注意：仅MSSQL2005及以上可用
    /// </summary>
    /// <param name="joinSql">join语句，如inner Join B on MenuInfo.fdMenuID=B.fdMenuID</param>
    /// <param name="throwSql">将SQL语句作为异常抛出，用于检测语句正确性</param>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2005_JOIN(string joinSql,bool throwSql,ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
    {
        return GetModelListMSSQL2005_JOIN(joinSql,throwSql,ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, 0, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// 注意：仅MSSQL2005及以上可用
    /// </summary>
    /// <param name="joinSql">join语句，如inner Join B on MenuInfo.fdMenuID=B.fdMenuID</param>
    /// <param name="throwSql">将SQL语句作为异常抛出，用于检测语句正确性</param>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="pageRecordOffset">分页时的偏移值（前面pageRecordOffset条使用其他方式或其他条件取出）</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2005_JOIN(string joinSql,bool throwSql,ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, int pageRecordOffset, params SqlParameter[] parms)
    {
        DataTable dt = GetListMSSQL2005_JOIN(joinSql,throwSql,ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, pageRecordOffset, parms);
        IList<MenuInfo_Model>
        modelList = new List<MenuInfo_Model>();
        foreach(DataRow dr in dt.Rows) modelList.Add(GetModel(dr));
        return modelList;
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// MSSQL2000及以上可用
    /// </summary>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2000(ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
    {
        DataTable dt = GetList(ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, parms);
        IList<MenuInfo_Model>
        modelList = new List<MenuInfo_Model>();
        foreach(DataRow dr in dt.Rows) modelList.Add(GetModel(dr));
        return modelList;
    }
    /// <summary>
    /// 分页返回符合条件的记录
    /// MSSQL2000及以上可用
    /// </summary>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2000(string conditionSql, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
    {
      string sql = SqlHelper.GetPageSQL(TableOrViewName, PrimeryKeyNames, conditionSql, "*", orderBy, pageSize, pageIndex);
      return GetModelList(sql, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// MSSQL2000及以上可用
    /// </summary>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="pageRecordOffset">分页时的偏移值（前面pageRecordOffset条使用其他方式或其他条件取出，小于0则表示最前面pageRecordOffset条记录被忽略）</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2000(ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, int pageRecordOffset, params SqlParameter[] parms)
    {
        DataTable dt = GetList(ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, pageRecordOffset, parms);
        IList<MenuInfo_Model>
        modelList = new List<MenuInfo_Model>();
        foreach(DataRow dr in dt.Rows) modelList.Add(GetModel(dr));
        return modelList;
    }
    /// <summary>
    /// 分页返回符合条件的记录
    /// MSSQL2000及以上可用
    /// </summary>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="pageRecordOffset">分页时的偏移值（前面pageRecordOffset条使用其他方式或其他条件取出，小于0则表示最前面pageRecordOffset条记录被忽略）</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2000(string conditionSql, string orderBy, int pageSize, int pageIndex, int pageRecordOffset, params SqlParameter[] parms)
    {
        string sql = SqlHelper.GetPageSQL(TableOrViewName, PrimeryKeyNames, conditionSql, "*", orderBy, pageSize, pageIndex, pageRecordOffset);
        return GetModelList(sql, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// MSSQL2000及以上可用
    /// </summary>
    /// <param name="joinSql">join语句，如inner Join B on MenuInfo.fdMenuID=B.fdMenuID</param>
    /// <param name="throwSql">将SQL语句作为异常抛出，用于检测语句正确性</param>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2000_JOIN(string joinSql,bool throwSql,ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
    {
        return GetModelListMSSQL2000_JOIN(joinSql,throwSql,ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, 0, parms);
    }
    /// <summary>
    /// 分页返回符合条件的记录，可指定返回字段
    /// MSSQL2000及以上可用
    /// </summary>
    /// <param name="joinSql">join语句，如inner Join B on MenuInfo.fdMenuID=B.fdMenuID</param>
    /// <param name="throwSql">将SQL语句作为异常抛出，用于检测语句正确性</param>
    /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
    /// <param name="conditionSql">指定条件(不含Where)</param>
    /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
    /// <param name="orderBy">排序方式(不包含order by)</param>
    /// <param name="pageSize">分页大小--每页包含的记录数</param>
    /// <param name="pageIndex">页码--要获取第几页的记录</param>
    /// <param name="pageRecordOffset">分页时的偏移值（前面pageRecordOffset条使用其他方式或其他条件取出）</param>
    /// <param name="parms">执行SQL语句使用的参数</param>
    /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
    public IList<MenuInfo_Model> GetModelListMSSQL2000_JOIN(string joinSql,bool throwSql,ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex,int pageRecordOffset, params SqlParameter[] parms)
    {
        DataTable dt = GetListMSSQL2000_JOIN(joinSql,throwSql,ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, pageRecordOffset, parms);
        IList<MenuInfo_Model>
        modelList = new List<MenuInfo_Model>();
        foreach(DataRow dr in dt.Rows) modelList.Add(GetModel(dr));
        return modelList;
    }
    /// <summary>
    /// Internal function to get cached parameters
    /// </summary>
    /// <returns></returns>
    private static SqlParameter[] GetMenuInfoParameters() {
    SqlParameter[] parms = SqlHelper.GetCachedParameters(SQL_INSERT_MENUINFO);
    if (parms == null) {
    parms = new SqlParameter[] {
    new SqlParameter(PARM_FD_MENU_ID , SqlDbType.Int)
    ,new SqlParameter(PARM_FD_MENU_NAME , SqlDbType.NVarChar , 50)
    ,new SqlParameter(PARM_FD_MENU_CODE , SqlDbType.VarChar , 50)
    ,new SqlParameter(PARM_FD_MENU_PARENT_ID , SqlDbType.Int)
    ,new SqlParameter(PARM_FD_MENU_URL , SqlDbType.VarChar , 50)
    ,new SqlParameter(PARM_FD_MENU_SORT , SqlDbType.Int)
    ,new SqlParameter(PARM_FD_MENU_IS_ENABLE , SqlDbType.Bit)
    ,new SqlParameter(PARM_FD_MENU_DESCRIPTION , SqlDbType.NVarChar , 350)
    ,new SqlParameter(PARM_FD_MENU_IS_TARGET , SqlDbType.Int)
    ,new SqlParameter(PARM_FD_MENU_PARENT_IDS , SqlDbType.NVarChar , 450)
    ,new SqlParameter(PARM_FD_MENU_IS_MENU_LAST , SqlDbType.Bit)
    ,new SqlParameter(PARM_FD_MENU_ICON , SqlDbType.VarChar , 50)
    };
    SqlHelper.CacheParameters(SQL_INSERT_MENUINFO, parms);
    }
    return parms;
    }
    }
 }
  
